home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 August: Tool Chest / Dev.CD Aug 00 TC Disk 2.toast / pc / sample code / quicktime / quicktime for java / zoo tutorial / module 8- transitions / source / mappane.java < prev    next >
Encoding:
Java Source  |  2000-06-23  |  5.4 KB  |  140 lines

  1. import java.awt.*;
  2. import java.awt.event.*;
  3. import java.io.*;
  4. import java.util.Hashtable;
  5.  
  6. import quicktime.*;
  7. import quicktime.qd.*;
  8. import quicktime.std.*;
  9. import quicktime.io.*;
  10. import quicktime.sound.*;
  11. import quicktime.std.image.*;
  12. import quicktime.std.music.*;
  13. import quicktime.std.movies.*;
  14. import quicktime.util.*;
  15. import quicktime.app.display.*;
  16. import quicktime.app.image.*;
  17. import quicktime.app.anim.*;
  18. import quicktime.app.actions.*;
  19.  
  20. import quicktime.app.event.QTActionEvent;  
  21. import quicktime.app.event.QTActionListener;
  22. import quicktime.app.event.QTMouseTargetController; 
  23.  
  24. import quicktime.app.audio.*;
  25.  
  26. import quicktime.app.QTFactory;
  27. import quicktime.std.movies.media.DataRef;
  28. import quicktime.app.players.QTPlayer;
  29.  
  30. /**
  31.  * QTZoo Module 7 - Switching between two compositors
  32.  * The Map pane that contains the main map interface
  33.  *
  34.  * @author Levi Brown
  35.  * @author Michael Hopkins
  36.  * @author Apple Computer, Inc.
  37.  * @version 1.0 10/21/1999
  38.  * Copyright:     © Copyright 1999 Apple Computer, Inc. All rights reserved.
  39.  *    
  40.  * Disclaimer:    IMPORTANT:  This Apple software is supplied to you by Apple Computer, Inc.
  41.  *                ("Apple") in consideration of your agreement to the following terms, and your
  42.  *                use, installation, modification or redistribution of this Apple software
  43.  *                constitutes acceptance of these terms.  If you do not agree with these terms,
  44.  *                please do not use, install, modify or redistribute this Apple software.
  45.  *
  46.  *                In consideration of your agreement to abide by the following terms, and subject
  47.  *                to these terms, Apple grants you a personal, non-exclusive license, under Apple’s
  48.  *                copyrights in this original Apple software (the "Apple Software"), to use,
  49.  *                reproduce, modify and redistribute the Apple Software, with or without
  50.  *                modifications, in source and/or binary forms; provided that if you redistribute
  51.  *                the Apple Software in its entirety and without modifications, you must retain
  52.  *                this notice and the following text and disclaimers in all such redistributions of
  53.  *                the Apple Software.  Neither the name, trademarks, service marks or logos of
  54.  *                Apple Computer, Inc. may be used to endorse or promote products derived from the
  55.  *                Apple Software without specific prior written permission from Apple.  Except as
  56.  *                expressly stated in this notice, no other rights or licenses, express or implied,
  57.  *                are granted by Apple herein, including but not limited to any patent rights that
  58.  *                may be infringed by your derivative works or by other works in which the Apple
  59.  *                Software may be incorporated.
  60.  *
  61.  *                The Apple Software is provided by Apple on an "AS IS" basis.  APPLE MAKES NO
  62.  *                WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED
  63.  *                WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  64.  *                PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN
  65.  *                COMBINATION WITH YOUR PRODUCTS.
  66.  *
  67.  *                IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR
  68.  *                CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
  69.  *                GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  70.  *                ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION
  71.  *                OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT
  72.  *                (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN
  73.  *                ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  74.  * 
  75.  * 
  76.  */
  77. public class MapPane extends ZooPane
  78. {
  79.     public MapPane( )
  80.     {
  81.         try
  82.         {
  83.             QDRect size = new QDRect(MainFrame.WIDTH, MainFrame.HEIGHT);
  84.             QDGraphics gw = new QDGraphics (size);
  85.             compositor = new Compositor (gw, QDColor.white, 20, 1);
  86.             
  87.             QTFile waterPict = new QTFile (QTFactory.findAbsolutePath ("data/map/water.pict"));
  88.             GraphicsImporterDrawer waterDrawer = new GraphicsImporterDrawer(waterPict);
  89.             waterDrawer.setDisplayBounds (size);
  90.             ImagePresenter water = ImagePresenter.fromGraphicsImporterDrawer(waterDrawer);
  91.             compositor.addMember(water, 6);
  92.  
  93.             QTFile                 islandFile = new QTFile( QTFactory.findAbsolutePath( "data/map/island.pict" ));
  94.             ImagePresenter         islandPresenter = ImagePresenter.fromFile( islandFile );
  95.             ImageDataSequence     islandDS = new ImageDataSequence (islandPresenter.getDescription());
  96.             
  97.             islandDS.addMember( islandPresenter.getImage() );
  98.  
  99.             if ((QTSession.isCurrentOS(QTSession.kWin32) && QTSession.getQTMajorVersion() == 3) == false)    //doesn't work on QT3.0.2 on Win
  100.                 islandDS = ImageUtil.makeTransparent ( islandDS, QDColor.white );
  101.  
  102.             Matrix theMatrix = new Matrix();
  103.             theMatrix.translate( (float) 10, (float) 5 );
  104.             TwoDSprite island = new TwoDSprite( islandDS, theMatrix, true, 2 );
  105.             
  106.             compositor.addMember(island, 4);            
  107.  
  108.             ctr = new QTMouseTargetController( false );
  109.             ctr.addQTMouseListener( new PaneMouseListener( QDColor.lightGray, QDColor.white, QDColor.darkGray ));
  110.             
  111.             compositor.addController (ctr);
  112.             
  113.             ctr.addMember( island );
  114.             
  115.             TwoDSprite currentSprite;
  116.             areas = new Hashtable(6);
  117.         }
  118.         catch (Exception e)
  119.         {
  120.             e.printStackTrace();
  121.         }
  122.     }
  123.  
  124.     /**
  125.      * Called to do any setup after being set as the client of the QTCanvas.
  126.      * May be used to start effects running, movies playing, etc.
  127.      */
  128.     public void start()
  129.     {
  130.     }
  131.  
  132.     /**
  133.      * Called to do clean up after being removed as the client of the QTCanvas.
  134.      * Should be used to stop effects running, movies playing, etc.
  135.      */
  136.     public void stop()
  137.     {
  138.     }
  139. }
  140.